//
//  MusicRecommendCell.m
//  艾听歌
//
//  Created by dllo on 16/5/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "MusicRecommendCell.h"
#import "MusicCollectionViewCell.h"


#define MUSICRECOMMENDCELL @"musicrecommendcell"



@interface MusicRecommendCell ()<UICollectionViewDataSource,UICollectionViewDelegate>
//@property (nonatomic, strong) UILabel *LikeLabel;
//@property (nonatomic, strong) UILabel *introducLabel;
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) UICollectionViewFlowLayout *flowLayout;

@end


@implementation MusicRecommendCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCollectionView];
    }
    return self;
}
- (void)createCollectionView
{
    
    self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
    self.flowLayout.itemSize = CGSizeMake(100 * FitWidth, 100 * fitHeight);
    self.flowLayout.minimumInteritemSpacing = 0.5;
    self.flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:self.contentView.bounds collectionViewLayout:self.flowLayout];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.contentView addSubview:self.collectionView];
//    self.collectionView.backgroundColor = [UIColor clearColor];
    self.collectionView.dk_backgroundColorPicker = DKColorPickerWithRGB(0xffffff, 0x9C9C9C);
//    self.collectionView.alpha = 0.6;
    self.collectionView.bounces = NO;
    // 注册
    [self.collectionView registerClass:[MusicCollectionViewCell class] forCellWithReuseIdentifier:MUSICRECOMMENDCELL];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.collectionView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);
    self.flowLayout.itemSize = CGSizeMake(175 * FitWidth, self.contentView.frame.size.height - 20);
    
   
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
   
    return self.data.count;
//    return 2;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    MusicCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:MUSICRECOMMENDCELL forIndexPath:indexPath];

    cell.dk_backgroundColorPicker = DKColorPickerWithRGB(0xffffff,0x9C9C9C);
    cell.alpha = 0.8;

    cell.NewCellModel = [self.data objectAtIndex:indexPath.row];
    return cell;
}

- (void)setNewMusicModel:(MusicModel *)NewMusicModel
{
    _NewMusicModel = NewMusicModel;
    self.data = [NSMutableArray arrayWithArray:_NewMusicModel.data];
    [self.collectionView reloadData];
}


@end
